<?php
class User_Model_Basic extends Zend_Db_Table_Abstract
{
	public function getallvideo($id_user)
	{
		$db = Zend_Registry::get('connectDB');
		$data = $db->fetchAll($db->select()->from('urlvideo')->joinInner('product','urlvideo.id_product=product.id_product')->where('urlvideo.id_user = ?',$id_user));
		return $data;
	}
	public function search($id_user,$content)
	{
		$db = Zend_Registry::get('connectDB');
		$where = $db->quoteInto('urlvideo.id_user = ? AND (name_video LIKE ? OR name_product LIKE ? OR urlvideo.updatedate LIKE ?)',$id_user,'%'.$content.'%');
		$data = $db->fetchAll($db->select()->from('urlvideo')->joinInner('product','urlvideo.id_product=product.id_product')->where($where));
		return $data;
	}
	public function getidcatelog($catelog)
	{
		$db = Zend_Registry::get('connectDB');
		$data = $db->fetchRow($db->select()->from('catelory',array('id_catelog','folder_category'))->where('name_catelog = ?',$catelog));
		return $data;
	}
	public function getallnamecatelog()
	{
		$db = Zend_Registry::get('connectDB');
		$data = $db->fetchAll($db->select()->from('catelory','name_catelog'));
		return $data;
	}
	public function getproduct($id_catelog)
	{
		$db = Zend_Registry::get('connectDB');
		$data = $db->fetchAll($db->select()->from('product','name_product')->where('id_catelog = ?',$id_catelog));
		return $data;
	}
	public function addvideoytb($name_video,$date,$path,$name_img,$path_img,$size_img,$id_product,$user,$id_server)
	{
		$db = Zend_Registry::get('connectDB');
		$data = array('name_video'=>$name_video,'updatedate'=>$date,'name_urlvideo'=>$path,'name_img'=>$name_img,'name_urlimg'=>$path_img,'size_img'=>$size_img,'id_product'=>$id_product,'id_user'=>$user,'id_serverup'=>$id_server);
		$insert = $db->insert('urlvideo',$data);
		return $insert;
	}
	public function addvideo($name_video,$date,$path_video,$size_video,$name_img,$path_img,$size_img,$id_product,$user,$server)
	{
		$db = Zend_Registry::get('connectDB');
		$data = array('name_video'=>$name_video,'updatedate'=>$date,'name_urlvideo'=>$path_video,'size_video'=>$size_video,'name_img'=>$name_img,'name_urlimg'=>$path_img,'size_img'=>$size_img,'id_product'=>$id_product,'id_user'=>$user,'id_serverup'=>$server);
		$insert = $db->insert('urlvideo',$data);
		return $insert;
	}
	public function status($id,$status)
	{
		$db = Zend_Registry::get('connectDB');
		$data = array('status'=>$status);
		$where = $db->quoteInto('id_user =?',$id);
		$update = $db->update('users',$data,$where);
		return $update;
	}
}